package game.game.network.cmd;

import json.JSONObject;
import entity.Position;
import entity.map.FieldEntity;
import game.engine.network.client.IControllerClient;
import game.engine.network.cmd.CmdServer;
import game.engine.network.cmd.EnumCommand;
import game.game.network.client.IGameClientController;

public class CmdSReturnCacheMap extends CmdServer
{

	protected static String IS_BLOCK = "isblock";

	public CmdSReturnCacheMap(JSONObject pObject)
	{
		super( pObject );
	}

	public CmdSReturnCacheMap(FieldEntity pFieldEntity)
	{
		super( EnumCommand.CMD_SERV_RETURN_CACHE_MAP );
		addParam( CmdSReturnPosition.POSITIONX , pFieldEntity.getPosition().getX() );
		addParam( CmdSReturnPosition.POSITIONY , pFieldEntity.getPosition().getY() );
		addParam( IS_BLOCK , pFieldEntity.isBlock() );
	}

	@Override
	public void execute( IControllerClient pController )
	{
		((IGameClientController)pController).execute( this );

	}

	public FieldEntity getFieldEntity()
	{
		FieldEntity fieldEntity = new FieldEntity(new Position( getPositionX(),getPositionY()));
		return fieldEntity;
	}
	
	public Integer getPositionX()
	{
		return (Integer) getParam( CmdSReturnPosition.POSITIONX );
	}

	public Integer getPositionY()
	{
		return (Integer) getParam( CmdSReturnPosition.POSITIONY );
	}

}
